package icu.jiapeng.DemoJava.controller;

import icu.jiapeng.DemoJava.entity.Request;
import icu.jiapeng.DemoJava.service.RequestService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RequestMapping("/callback")
@RestController
public class CallBackController {
    @Resource
    private RequestService requestService;
    @RequestMapping("/v1")
    public Request callback(HttpServletRequest request, @RequestBody(required = false) String body, @RequestParam(required = false) Map<String,Object> params){
        return requestService.saveRequest(request, body, params);
    }
}
